package com.hzbank.game.mini.controller;


import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

import javax.annotation.Resource;

import org.apache.tomcat.util.codec.binary.Base64;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import com.hzbank.game.mini.service.BackgroundService;
import com.hzbank.game.mini.service.GuessGameService;
import com.hzbank.game.mini.vo.GuessVo;
import com.hzbank.game.mini.vo.GuessResultVo;

@Controller
@RequestMapping("/guess")
public class GuessController {
	
	@Autowired 
	private GuessGameService guessGameService;
	
    /*
     * 异步处理用户提交请求
     * */
	@Async
	@PostMapping("/commitAnswer")
	public List<GuessResultVo> commitAnswer(@RequestBody GuessVo GuessVo) {
	 guessGameService.sort(GuessVo);
	 return null;
	}
	
	
	/*
	 * 接收主持人提交的答案
	 * */
	@GetMapping("/commitResult")
	public boolean uploadCode(@RequestParam(name="result",required = true) String result) {
		guessGameService.saveResult(result);
		return true;
	}
}
